<template>
  <div>
    <!-- 面包屑导航 -->
    <el-bread></el-bread>
    <!-- 添加按钮 -->
    <el-button
      @click="addDialog"
      class="btnInfo"
      type="primary"
      size="small"
      plain
      >添加</el-button
    >
    <!-- 列表展示表格 -->
    <v-list @edit="edit"></v-list>
    <!-- 弹框的展示 -->
    <v-dialog
      ref="diaInfo"
      @cancel="cancel"
      :isShow="isShow"
      :isAdd="isAdd"
    ></v-dialog>
  </div>
</template>

<script>
//引入封装好的列表文件
import vList from "./list.vue";
import vDialog from "./dialog.vue";
export default {
  data() {
    return {
      isShow: false, //用来控制弹框的显示隐藏
      isAdd: true, //true 添加
    };
  },
  components: {
    vList,
    vDialog,
  },
  methods: {
    //封装一个打开弹框的事件
    addDialog() {
      //让弹框显示
      this.isShow = true;
      //告诉弹框你是一个添加
      this.isAdd = true;
    },
    //子组件要修改父的弹框显示状态
    cancel(e) {
      this.isShow = e;
    },
    //edit封装编辑打开弹框
    edit(e) {
      this.isShow = true;
      //告诉弹框你是一个编辑
      this.isAdd = false;
      // console.log(e,'要编辑的id')
      // console.log(this.$refs.diaInfo,'99999');
      this.$refs.diaInfo.lookup(e);
    },
  },
};
</script>

<style lang="less" scoped>
.btnInfo {
  margin: 10px 5px;
}
</style>
